<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div>0</div>
    <script>
      //   let timer = null;
      //   let box = document.querySelector("div");
      //   box.addEventListener("mousemove", () => {
      //     if (timer) {
      //       clearTimeout(timer);
      //     }
      //     timer = setTimeout(() => {
      //       box.innerHTML++;
      //     }, 1000);
      //   });
      let timer = null;
      let box = document.querySelector("div");
      box.addEventListener("mousemove", function () {
        if (timer == null) {
          timer = setTimeout(function () {
            box.innerHTML++;
            timer = null;
          }, 1000);
        }
      });
    </script>
  </body>
</html>
